﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JeanFish.Blog.Business
{
    public sealed class User : UserBase
    {
        public Guid ID
        {
            get { return Guid.Parse(this._id); }
            set { this.SetProperty<string>("ID", value.ToString("N"), ref this._id); }
        }
        public string Name
        {
            get { return this._name; }
            set
            {
                this.SetProperty<string>("Name", value, ref this._name);
            }
        }
        public string Username
        {
            get { return this._username; }
            set
            {
                this.SetProperty<string>("Username", value, ref this._username);
            }
        }
        public string Password
        {
            get { return this._password; }
            set
            {
                this.SetProperty<string>("Password", value, ref this._password);
            }
        }
        public static implicit operator User(Storage.User user)
        {
            var u = new User();
            u.Copy(user);
            return u;
        }
        public bool Validate(string username, string password)
        {
            return this.Username == username && this.Password == password;
        }
        public sealed override void AcceptChanges()
        {
            base.AcceptChanges();
        }

        protected async override Task<SavedResult> SaveAsync()
        {
            return await Task.FromResult(SavedResult.OK);
        }
    }
}
